home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1996 July: Mac OS SDK / Dev.CD Jul 96 SDK / Dev.CD Jul 96 SDK1.toast / Development Kits (Disc 1) / OpenDoc / OpenDoc Development / Debugging Support / OpenDoc Source Code / DocShell / DraftWn.h < prev    next >
Encoding:
C/C++ Source or Header  |  1996-04-22  |  8.3 KB  |  275 lines  |  [TEXT/MPS ]

  1. /*
  2.     File:        DraftWn.h
  3.  
  4.     Contains:    definition of the DraftWin and DraftInfoRec classes
  5.  
  6.     Owned by:    Eric House
  7.  
  8.     Copyright:    © 1993 - 1995 by Apple Computer, Inc., all rights reserved.
  9.  
  10.     Change History (most recent first):
  11.  
  12.         <18>      9/8/95    TÇ        1252120 FB1: New documents saved w/ StdFile
  13.                                     & trashed if closed w/o saving
  14.         <17>      9/7/95    EL        1281410: Extra session parameter in
  15.                                     DeleteSelectedDraft so it can open and
  16.                                     close draft and rename windows.
  17.         <16>     8/29/95    TJ        The Method for ~DummyDraftInfoRec is only
  18.                                     defined in debug builds. Set the Class
  19.                                     definition to match it.
  20.         <15>     8/25/95    eeh        1230007: cleanup
  21.         <14>     8/25/95    eeh        1230007: dummy recs etc. (incomplete)
  22.         <13>     8/16/95    eeh        1248265: add fReadyToClose
  23.         <12>     7/18/95    eeh        1222282 (partial): new param to MakeAList
  24.         <11>     5/18/95    eeh        1236414: add hasWriteAccess param to
  25.                                     Drafts()
  26.         <10>     5/10/95    eeh        1239830 : add kDraftWinLowMemAbort;
  27.                                     1215536: add DraftSaved and get/setters for
  28.                                     DraftWindow fields
  29.          <9>      5/4/95    eeh        1232095: add DeleteSelectedDraft
  30.          <8>     4/14/95    TÇ        #1235279 BB: InfoUtil & StdTypIO functions
  31.                                     should take Environment* and SU* when
  32.                                     possible
  33.          <7>     4/10/95    EL        1215536: extra parameter in
  34.                                     InitDraftInfoRec so we can get the next
  35.                                     draft property.
  36.          <6>     3/24/95    eeh        1229961, 1215528: change callbacks to use
  37.                                     IText*
  38.          <5>     3/15/95    eeh        1193824: added fListH, fListRect, and
  39.                                     fCreateSet
  40.          <4>    12/19/94    eeh        1192626: change params to MakeAList and
  41.                                     Drafts
  42.          <3>     8/29/94    TÇ        #1183567 StdTypIO routine implementation &
  43.                                     fixup
  44.          <2>     6/27/94    TÇ        added fEV to DraftWindow and
  45.                                     DraftInfoRec
  46.          <1>     6/27/94    TÇ        first checked in
  47.          <0>     6/27/94    SV        SOMverted
  48.         <10>      5/3/94    eeh        bug #1155857: param changes to MakeAList
  49.                                     and GetUserStrings
  50.          <9>     3/31/94    eeh        bug #1153999: made fModifiedBy a ODIText*
  51.          <8>      2/8/94    JA        Minor tweaks for CodeWarrior.
  52.          <7>     1/25/94    NP        TÇ: implemented
  53.          <6>     1/14/94    TÇ        added some skeleton code from HI
  54.          <5>     1/13/94    TÇ        reworked apis for latest round of HI
  55.                                     changes
  56.          <4>     8/24/93    TÇ        removed code made obsolete by HI Changes
  57.          <3>     8/18/93    TÇ        removed SetPreviousComment support
  58.          <2>     8/11/93    TÇ        move property & type constants to StdProps
  59.                                     and StdTypes
  60.          <1>     7/14/93    TÇ        first checked in
  61.  
  62.     To Do:
  63. */
  64.  
  65. #ifndef _DRAFTWN_
  66. #define _DRAFTWN_
  67.  
  68. #ifndef _PLFMDEF_
  69. #include "PlfmDef.h"
  70. #endif
  71.  
  72. #ifndef SOM_ODDraft_xh
  73. #include <Draft.xh>
  74. #endif
  75.  
  76. #ifndef __DIALOGS__
  77. #include <Dialogs.h>
  78. #endif
  79.  
  80. #ifndef __LISTS__
  81. #include <Lists.h>
  82. #endif
  83.  
  84. //==============================================================================
  85. // Constants
  86. //==============================================================================
  87.  
  88. #define kDraftWinNone            0
  89. #define kDraftWinOpen            1
  90. #define    kDraftWinDone            2
  91. #define kDraftWinCreate            3
  92. #define    kDraftWinDelete            4
  93. #define    kDraftWinLowMemAbort    5
  94.  
  95. //==============================================================================
  96. // Scalar Types
  97. //==============================================================================
  98.  
  99. typedef    ODULong    DraftWinAction;
  100. struct DWStringsArray ;
  101.  
  102. enum DraftInfoRecType { kDIRTypeUnknown, kDIRTypeFull, kDIRTypeDummy };
  103.  
  104. //==============================================================================
  105. // Classes defined in this interface
  106. //==============================================================================
  107.  
  108. class DraftWindow;    // very platform dependent
  109. class DraftInfoRec;
  110. class DummyDraftInfoRec;
  111. class FullDraftInfoRec;
  112.  
  113. //==============================================================================
  114. // Classes used by this interface
  115. //==============================================================================
  116.  
  117. class DraftInfoRec 
  118. {
  119. public:
  120.     DraftInfoRec();
  121.     ODVMethod    ~DraftInfoRec();
  122.  
  123.     ODMethod    DraftInfoRecType    GetDIRType()    { return fDIRType; }
  124.  
  125.     // I really don't need First() anymore.
  126. //    ODMethod    DraftInfoRec*    First()     { return fFirst; }
  127.     ODMethod    DraftInfoRec*    Next()         { return fNext; }
  128.     ODMethod    void            SetNext(DraftInfoRec* next)
  129.                 {fNext = next; }
  130.     ODMethod    ODBoolean        ShouldHilite()    { return fShouldHilite; }
  131.     ODMethod    void        SetShouldHilite( ODBoolean should )
  132.                 { fShouldHilite = should ; }
  133.  
  134.     ODMethod    ODIText*    GetComment()    { return fComment; }
  135.     ODMethod    void    SetComment( ODIText* comment)    { fComment = comment; }
  136.  
  137. protected:
  138.     ODMethod    void                SetDIRType(DraftInfoRecType typ)
  139.                 { fDIRType = typ; }
  140.  
  141. private:
  142.     DraftInfoRecType    fDIRType;
  143.     DraftInfoRec*        fNext;
  144. //    DraftInfoRec*        fFirst;
  145.     ODBoolean            fShouldHilite;
  146.     ODIText*            fComment;
  147. };
  148.  
  149. class DummyDraftInfoRec : public DraftInfoRec
  150. {
  151. public:
  152.     DummyDraftInfoRec();
  153. #if ODDebug
  154.     ODVMethod    ~DummyDraftInfoRec();
  155. #endif
  156.     ODMethod    void    SetCommentOwner( FullDraftInfoRec* owner)
  157.             { fCommentOwner = owner; }
  158.     ODMethod    FullDraftInfoRec*    GetCommentOwner()
  159.             { return fCommentOwner; }
  160.     
  161. private:
  162.     FullDraftInfoRec*     fCommentOwner;
  163. };
  164.  
  165. class FullDraftInfoRec : public DraftInfoRec
  166. {
  167. public:
  168.  
  169.     FullDraftInfoRec();
  170.     ODNVMethod    void    InitDraftInfoRec(Environment* ev, ODDraft* draft);
  171.         // note: draft reference is consumed in Init and released in destructor
  172.     ODVMethod    ~FullDraftInfoRec();
  173.     
  174.     ODMethod    ODULong            Number()    { return fDraftNumber; }
  175.     ODMethod    void            SetNumber(ODULong num)
  176.                                             { fDraftNumber = num; }
  177.     ODMethod    ODDraft*        Draft()        { return fDraft;    }
  178.     
  179.     ODMethod    ODIText*    GetNumberString()    {return fDraftNumberString;}
  180.     ODMethod    void        SetNumberString(ODIText* str)
  181.                                                 {fDraftNumberString = str;}
  182.     ODMethod    ODIText*    GetCreated()        {return fSavedString;}
  183.     ODMethod    ODIText*    GetModifiedBy()        {return fModifiedBy;}
  184.  
  185.     ODMethod    ODBoolean    IsExpanded()    { return fCachedComment != kODNULL;}
  186.  
  187.     ODMethod    void        CacheComment()
  188.             { fCachedComment = GetComment(); SetComment(kODNULL); }
  189.     ODMethod    void        UncacheComment()
  190.             { SetComment(fCachedComment); fCachedComment = kODNULL; }
  191. #if ODDebug
  192.     ODMethod    ODIText*    GetCachedComment() { return fCachedComment; }
  193. #endif
  194.  
  195.     ODMethod    ODBoolean    CanExpand()        { return fCanExpand; }
  196.             // The only thing to set this to is true.
  197.     ODMethod    void        SetCanExpand()    { fCanExpand = kODTrue; }
  198.  
  199. private:
  200.     ODDraft*        fDraft;
  201.     ODStorageUnit*    fDraftProperties;
  202.     ODDraftID        fDraftID;
  203.     ODULong            fDraftNumber;
  204.     ODIText*        fDraftNumberString;
  205.     ODULong            fSaved;
  206.     ODIText*        fSavedString;
  207.     ODIText*        fCachedComment;        // null unless expanded
  208.     ODIText*        fModifiedBy;
  209.     ODBoolean        fCanExpand;        // the comment is too long and may be expanded
  210. };
  211.  
  212.  
  213. //==============================================================================
  214. // DraftWindow
  215. //==============================================================================
  216.  
  217. class DraftWindow
  218. {    
  219.   public:
  220.  
  221.     DraftWindow();
  222.     ODNVMethod void     InitDraftWindow(Environment* ev, ODDraft* draft);
  223.     ODVMethod         ~DraftWindow();
  224.  
  225.     ODMethod    DraftWinAction    Drafts(Environment* ev, ODDraft* draft,
  226.             DraftWinAction prevAction, ODBoolean hasWriteAccess);
  227.     ODMethod    FullDraftInfoRec*    InternalizeHistory(Environment*    ev);
  228.     ODMethod    ODDraft*            GetSelectedDraft()    {return fSelectedDraft;}
  229.     
  230.     //ODMethod    void    DraftCreated(Environment* ev, ODDraft* draft);    
  231.     ODMethod    void    DraftSaved(Environment* ev, ODDraft* draft);    
  232.     // used to set the Draft Properties
  233.     // can be used independently of other methods including initialize
  234.  
  235.  
  236.     ODMethod    ODSShort    CountDrafts() ;    
  237.     ODMethod    ListHandle    GetListHandle() {return fListH;}    
  238.     ODMethod    ODBoolean    CreateIsSet() {return fCreateSet;}
  239.     ODMethod    void        SetReadyToClose(ODBoolean readyToClose)
  240.                 { fReadyToClose = readyToClose; }
  241.     ODMethod    ODBoolean    ReadyToClose()
  242.                 { return fReadyToClose; }
  243.     ODMethod    void        GetListRect(Rect* r) {*r = fListRect;}
  244.     ODMethod    void        DeleteSelectedDraft(Environment* ev, ODSession* session);
  245.  
  246.     ODMethod    void        SetHilite( DraftInfoRec* from, short whichRow );
  247.     ODMethod    ODBoolean    ProcessMousedownInList( DialogPtr dialog,
  248.         ListHandle listH, Point mpt );
  249.  
  250.   protected:
  251.       ODMethod    ODBoolean    CreateDraft(Environment* ev);
  252.       ODMethod    ODBoolean    RemoveSelectedDrafts(Environment* ev);
  253.     ODMethod    void    Print();
  254.  
  255.     ODMethod    ListHandle MakeAList( DialogPtr dlg, ODSShort* numLines,
  256.         long refcon );
  257.         
  258. #if ODDebug
  259.     ODMethod    void    CheckConsistency();
  260. #endif
  261.   private:
  262.     ODDraft*            fDraft;
  263.     ODDocument*            fDocument;
  264.     FullDraftInfoRec*    fDraftInfo;
  265.     ODDraft*            fSelectedDraft;
  266.     ODULong                fSelectedDraftNumber;
  267.     ListHandle            fListH;
  268.     Rect                fListRect;
  269.     ODBoolean            fCreateSet;
  270.     FullDraftInfoRec*    fHilitedRow;
  271.     ODBoolean            fReadyToClose;
  272. };
  273.  
  274. #endif    // _DRAFTWIN_
  275.